package com.lxg.service.booksService.impl;

import com.lxg.dao.BooksDao;
import com.lxg.pojo.Books;
import com.lxg.service.booksService.BooksShowService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;

@Service
public class BookShowServiceImpl implements BooksShowService {
    @Autowired
    BooksDao booksDao;

    /**
     * 按照订阅次数排序
     * 查询全部书本
     * @return
     */
    @Override
    public ArrayList<Books> getAllBooks() {
        ArrayList<Books> allBooks = booksDao.getAllBooks();
        return allBooks;
    }

    /**
     * 根据图书bid查询唯一对应图书
     * @return
     */
    @Override
    public Books getBookByBid(Integer bid) {
        Books book = booksDao.getBookByBid(bid);
        return book;
    }

    /**
     * 根据书本bid模糊查询
     * @param bid
     * @return
     */
    @Override
    public ArrayList<Books> getAllLikeBooksByBid(Integer bid) {
        ArrayList<Books> books = booksDao.getAllLikeBooksByBid(bid);
        return books;
    }

    /**
     * 根据书本名字模糊查询
     * @param name
     * @return
     */
    @Override
    public ArrayList<Books> getAllLikeBooksByName(String name) {
        ArrayList<Books> books = booksDao.getAllLikeBooksByName(name);
        return books;
    }

    /**
     * 根据书本作者模糊查询
     * @param author
     * @return
     */
    @Override
    public ArrayList<Books> getAllLikeBooksByAuthor(String author) {
        ArrayList<Books> books = booksDao.getAllLikeBooksByAuthor(author);
        return books;
    }
}
